<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>能耗监测</title>
<script type="text/javascript">
	
</script>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../js/Calender.js"></script>
<script type="text/javascript">

   $(document).ready(function(){
	   
	   $('#select1').blur(function(){
		   var select1=document.getElementById('select1').value;
		   getSelect1(select1)
	   })
	   
	   $('#sect1').blur(function(){
		   var sect1=document.getElementById('sect1').value;
		   getSect1(sect1)
	   })
   })
   
   function getSelect1(select1){
	   $.ajax({
		   type:'post',
		   url:'${pageContext.request.contextPath}/consums/getSelect1.action',
		   data:'select1='+select1,
		   success:function(data){
			   init()
		   }	   
	   })
   }
   function getSect1(sect1){
	   $.ajax({
		   type:'post',
		   url:'${pageContext.request.contextPath}/consums/getSect1.action',
		   data:'sect1='+sect1,
		   success:function(data){
			   searchName(1)
		   }
	   })
   }
   
   
   function searchName(num){

	   $.ajax({
		   type:'post',
		   url:'${pageContext.request.contextPath}/consums/searchName.action',
		   success:function(data){
			  init()
		   }
	   })
   }
   
	function setList() {
		$.ajax({
			type : 'post',
			url : '${pageContext.request.contextPath}/consums/setList.action',
			success : function(data) {
				init()
			}
		});
	}

	function init() {
		window.location.href = "${pageContext.request.contextPath}/consums/getList.action";
	}
	
	function deleteThis(id) {
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/consums/deleteThis.action',
			data:'id='+id,
			success:function(data){
				init()
			}
		});
	}
</script>
<base href="${pageContext.request.contextPath}/xiao">
</head>
<body>


	能源种类：

	<select name="option1" id="sect1">
		<c:forEach items="${optionList}" var="consums">
			<option value="${consums.various}">${consums.various}</option>
		</c:forEach>
	</select>



	<button onclick="setList()">显示全部数据</button>
	<a href="consums/insertThis.action">增加能源种类</a>
	<table cellspacing="0" cellpadding="0" border="1" width="1000px"
		style="text-align: center">
		<tr>
			<td>ID</td>
			<td>能源种类</td>
			<td>能源消耗总量</td>
			<td>本月预期消耗</td>
			<td>本月实际消耗</td>
			<td>操作</td>
		</tr>

		<c:forEach items="${consumList}" var="consums" begin="0" end="50">
			<tr>
				<td>${consums.id}</td>
				<td>${consums.various}</td>
				<td>${consums.total}</td>
				<td>${consums.expect}</td>
				<td>${consums.actual}</td>
				<td><a href="consums/updateThis.action?id=${consums.id}">修改</a>
					<button onclick="deleteThis(${consums.id})">删除</button></td>

			</tr>
		</c:forEach>
	</table>


<br>
<select id="select1" name="select1">
     <option value="jsp/a.jsp">3D环形图</option>
     <option value="jsp/a2.jsp">动态柱状图</option>
  </select>
<hr>

  
	<iframe src="${jsppage}" id="myiframe" scrolling="no" frameborder="0"
		style="width: 1100px; height: 2000px;">这是A</iframe>

</body>
</html>